﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

namespace MetaHeuristics.Demo
{
    using MetaHeuristics.Tsp;
    using MetaHeuristics.Aco;

    class Program
    {
        static AcoTspRenderer render;
        static AcoForTspAlgorithm aco;
        static void Main(string[] args)
        {
            try
            {
                Burma14TspProblem tsp = new Burma14TspProblem();
                aco = new AcoForTspAlgorithm(tsp);
                aco.Daemons.Add(new EllitistAntDaemonAction());

                render = new AcoTspRenderer(aco);
                //render.RoutesEnabled = false;
                aco.BestAntChanged += new EventHandler(aco_BestAntChanged);
                Console.WriteLine(aco);

                Console.Out.Flush();
                aco.Solve();
                Console.WriteLine(aco.BestAnt);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            Console.ReadLine();
        }

        static void aco_BestAntChanged(object sender, EventArgs e)
        {
                Console.WriteLine("{0} {1} {2}",aco.BestAnt.Tours.Length,
                    aco.Pheromones.Min,aco.Pheromones.Max
                    );

                Console.WriteLine(aco.BestAnt);

                render.Render(String.Format("tsp{0:0000}.png",aco.IterationCount), 400,200);
        }
    }
}
